Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[types] Add type definitions from DefinitelyTyped/DefinitelyTyped#62510 #221

Merged
merged 5 commits into from
Oct 13, 2022

Conversation

MysteryBlokHed
Copy link
Member

@MysteryBlokHed MysteryBlokHed commented Oct 2, 2022

Closes #119

Moves types from the original DefinitelyTyped PR and adds some dependencies and workflows to test them.

This PR is still very much a work in progress, and I'm pretty sure there are some parts of the API that I haven't typed yet.

Moves types from the original DefinitelyTyped PR and adds some
dependencies and workflows to test them.

These changes are super broken on my machine right now and I can't
figure out why, but I'll try to get it fixed.
@LeaVerou
Copy link
Member

LeaVerou commented Oct 3, 2022

Wow, that is a very substantial amount of work, thank you so much @MysteryBlokHed!

I'm a bit worried I lack the TS experience to review this properly, perhaps someone else could take a look when it's ready? @ai @jgerigmeyer would that be of interest to you?

@jgerigmeyer
Copy link
Member

@jgerigmeyer would that be of interest to you?

Yes, I'd be happy to take a look at this! I should be able to do that in the next few days. 👍

@MysteryBlokHed
Copy link
Member Author

I think most of the API has types now. I just need to figure out the best way to add types for the space accessors

Copy link
Member

@jgerigmeyer jgerigmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so helpful -- thanks @MysteryBlokHed! 🎉

I wasn't able to get dtslint running locally without some further changes -- submitted in MysteryBlokHed#1

I pulled this in to a personal TypeScript project that uses colorjs.io (replacing some type stubs I'd written there), and there were only a few places where it seems these types were slightly incorrect -- I submitted a first pass at some changes in MysteryBlokHed#2

* Initial round of types review

* Address review
Copy link
Member

@jgerigmeyer jgerigmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@MysteryBlokHed MysteryBlokHed marked this pull request as ready for review October 11, 2022 21:50
@LeaVerou
Copy link
Member

@jgerigmeyer thank you so much! I just added you as a collaborator.

@MysteryBlokHed @jgerigmeyer is this ready to merge?

"src/",
"types/dist/",
"types/src/",
"types/index.d.ts"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we choose this structure over src/types and dist/types? Is that the convention? (no problem if that's the case, just thought I'd ask)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just kept this structure when I copied the types over from DefinitelyTyped, but I think doing it this way also makes testing easier since everything's in the same place

- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "12"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't 12 a bit old at this point?

Copy link
Member Author

@MysteryBlokHed MysteryBlokHed Oct 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I chose 12 because the Babel config specifies version <=12, but it could be made more recent

@@ -1,4 +1,4 @@
dist/
/dist/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the leading slash means that Git will only ignore the dist folder in the root of the project. Without this change, the folder types/dist is also ignored

@LeaVerou
Copy link
Member

I had a quick look and left some questions.

I see there is also a new test directory with different tests. How does this compare to the existing tests? Are they complementary? Is it primarily testing types? We should probably document why there are two different sets of tests somewhere, for new contributors?

@jgerigmeyer
Copy link
Member

I'm 99% sure that we'll discover small issues once people start actually using this with TypeScript, but IMO this is already a significant improvement and is ready to merge. 🎉

It would be much easier to maintain these types going forward if the codebase itself were re-written in TypeScript, but I understand that's not a simple change and wouldn't have to happen right away regardless.

@MysteryBlokHed
Copy link
Member Author

MysteryBlokHed commented Oct 13, 2022

I see there is also a new test directory with different tests. How does this compare to the existing tests? Are they complementary? Is it primarily testing types? We should probably document why there are two different sets of tests somewhere, for new contributors?

The tests in the types directory only test the definitions; they're not actually evaluated like the existing tests.

A mention of the reason for the two directories could be mentioned in the README or CONTRIBUTING files maybe? I could make a change when I'm free in a few hours

@LeaVerou
Copy link
Member

I'm 99% sure that we'll discover small issues once people start actually using this with TypeScript, but IMO this is already a significant improvement and is ready to merge. 🎉

Ok, I plan to rebase and merge soon, so if there's anything you want to squash in the commit log, now's the time.

It would be much easier to maintain these types going forward if the codebase itself were re-written in TypeScript, but I understand that's not a simple change and wouldn't have to happen right away regardless.

I know, but I don't want to tie the source to a build tool, it's nice that right now things like this work in a browser: import Color from "https://colorjs.io/src/color.js". I think having separate typing files is a nice compromise, though they do double the number of files 😕

@LeaVerou
Copy link
Member

I see there is also a new test directory with different tests. How does this compare to the existing tests? Are they complementary? Is it primarily testing types? We should probably document why there are two different sets of tests somewhere, for new contributors?

The tests in the types directory only test the definitions; they're not actually evaluated like the existing tests.

A mention of the reason for the two directories could be mentioned in the README or CONTRIBUTING files maybe? I could make a change when I'm free in a few hours

I totally missed they were in types. I think that's pretty self-explanatory, though of course you're welcome to add something in CONTRIBUTING.md if you feel like it.

@jgerigmeyer
Copy link
Member

Ok, I plan to rebase and merge soon, so if there's anything you want to squash in the commit log, now's the time.

I'm not particular about a "clean" git history, so I'll defer to @MysteryBlokHed on whether to squash before merging.

@MysteryBlokHed
Copy link
Member Author

Rebasing seems fine and I don't think there's anything else that needs changing right now

@LeaVerou LeaVerou merged commit efcd444 into color-js:main Oct 13, 2022
@LeaVerou
Copy link
Member

Merged, thank you both!

@1nfinity-5starZ
Copy link

Was this shipped in latest release ?

@LeaVerou
Copy link
Member

No, it will be in the next release (likely v0.4.1)

@MysteryBlokHed MysteryBlokHed deleted the types/add-definitions branch October 21, 2022 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typescript support
4 participants